//
//  JKAlert.m
//  LCPackage
//
//  Created by 马军凯 on 2021/6/29.
//  Copyright © 2021 龙采科技集团. All rights reserved.
//

#import "JKAlert.h"

@implementation JKAlert

//alert显示内容
+ (void)showMessage:(NSString *)message {
    [self showTitle:nil message:message cancelBtn:NO completion:nil];
}
//alert显示内容
+ (void)showMessage:(NSString *)message cancelBtn:(BOOL)cancelBtn completion:(void(^)(void))completion {
    [self showTitle:nil message:message cancelBtn:cancelBtn completion:^{
        if (completion) {
            completion();
        }
    }];
}

//带标题显示
+ (void)showTitle:(NSString *)title message:(NSString *)message {
    [self showTitle:title message:message cancelBtn:NO completion:nil];
}
//带标题显示
+ (void)showTitle:(NSString *)title message:(NSString *)message cancelBtn:(BOOL)cancelBtn completion:(void (^)(void))completion {
    //创建alert
    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    //取消
    if (cancelBtn == YES) {
        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
        [alertVC addAction:cancelAction];
    }
    //确认
    UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (completion) {
            completion();
        }
    }];
    [alertVC addAction:sureAction];
    
    //添加
    [[UIApplication getCurrentVC] presentViewController:alertVC animated:YES completion:nil];
}


@end
